﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BLL;
using Entity;
namespace BookStore.Controllers
{
    public class AdminController : Controller
    {
        //
        // GET: /Admin/Index

        public ActionResult Index()
        {
            return View();
        }
        //管理员信息列表
        public ActionResult AdminMessage()
        {
            ViewBag.tt = L_AdminBLL.SelectAdminMessage();
            return View();
        }
        //删除管理员信息
        public ActionResult AdminMessagee(string UserId)
        {
            UserInfo f = new UserInfo();
            f.UserId = Convert.ToInt32(UserId);
            L_AdminBLL.UpdataAdmin(f);
            return RedirectToAction("AdminMessage");
        }
        //客户信息列表
        public ActionResult customerMessage()
        {
            ViewBag.tt = L_AdminBLL.SelectCustomer();
            return View();
        }
        //个人信息修改
        public ActionResult MyMessage()
        {
            string UserId = Request["UserId"];
            UserInfo f = new UserInfo();
            f.UserId = Convert.ToInt32(UserId);
            ViewBag.tt = L_AdminBLL.UpdateMessage(f);
            return View();
         
        }
        [HttpPost]
        public ActionResult MyMessage(string UserPwd, string UserId, int  UserPower)
        {
            UserInfo f = new UserInfo();
            f.UserId = Convert.ToInt32(UserId);
            f.UserPwd = UserPwd;
            f.UserPower = UserPower;
            L_AdminBLL.UpdataTypeName(f);
            return RedirectToAction("AdminMessage");
        }
        public ActionResult AdminUpdateCustomer()
        {

            string UserId = Request["UserId"];
            UserInfo u = new UserInfo();
            u.UserId =Convert.ToInt32(UserId);
            L_AdminBLL.updateCustomer(u);
            return RedirectToAction("customerMessage");  
        }
    }
}
